
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page import="pl.swspiz.*" %>
<%@page import="java.util.*" %>

<% User currentUser = (User)(session.getAttribute("currentSessionUser"));
if (currentUser == null){

%>
<jsp:forward page="/LoginPage.jsp"/>

<% } %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Lista</title>
    </head>
    <body>
<%
if (request.getAttribute("records") == null){
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/listRecords");
dispatcher.include(request,response);
}
%>
Zalogowany:
 <%= currentUser.getFirstName() %>
    <h1>Lista jednostek miar dostepna w bazie danych</h1>
    
<table id="personListTable" border="0">
<tr >
    <th bgcolor=>Nazwa</th>
    <th bgcolor=>Mnoznik</th>
    <th>&nbsp;</th>
    <th>&nbsp;</th>
</tr>
<%Iterator itr;%>
<% List records= (List)request.getAttribute("records");
for (itr=records.iterator(); itr.hasNext(); )
{
Unit element = (Unit) itr.next();
out.println("<tr>");
out.println("<td>" + element.getName() + "</td>");
out.println("<td>" + element.getWsp() + "</td>");

out.println("<td><a href=\"unitEdit?do=edit&id=" + element.getName() + "\">Edycja</a></td>");
out.println("<td><a href=\"unitEdit?do=delete&id=" + element.getName() + "\" onclick=\"return confirm('Czy na pewno skasowac wpis?')"+"\">Usun</a></td>");
out.println("</tr>");

}
%>


</table>
<br>
<a href="unitEdit.jsp"><strong>Dodaj wpis</strong></a>
<a href="index.jsp"><strong>Strona główna</strong></a>

</body>
</html>
